﻿Jxstar.currentPage = function() {
	var config = {param:{},initpage:function(page, define){},eventcfg:{}};

	var cols = [
	{col:{header:'物资编码', width:134, sortable:true}, field:{name:'store_mat__mat_code',type:'string'}},
	{col:{header:'物资名称', width:210, sortable:true}, field:{name:'store_mat__mat_name',type:'string'}},
	{col:{header:'型号', width:100, sortable:true}, field:{name:'store_mat__mat_size',type:'string'}},
	{col:{header:'物资分类', width:100, sortable:true}, field:{name:'store_mat__type_name',type:'string'}},
	{col:{header:'分类编码', width:100, sortable:true}, field:{name:'store_mat__type_code',type:'string'}},
	{col:{header:'单位', width:100, sortable:true}, field:{name:'store_mat__mat_unit',type:'string'}},
	{col:{header:'单价(元)', width:100, sortable:true, align:'right',renderer:JxUtil.formatNumber(2)}, field:{name:'store_mat__mat_price',type:'float'}},
	{col:{header:'分类ID', width:100, sortable:true, colindex:10000, hidden:true}, field:{name:'store_mat__type_id',type:'string'}},
	{col:{header:'主键', width:100, sortable:true, colindex:10000, hidden:true}, field:{name:'store_mat__mat_id',type:'string'}},
	{col:{header:'备注', width:100, sortable:true, hidden:true}, field:{name:'store_mat__mat_desc',type:'string'}}
	];
	
	config.param = {
		cols: cols,
		sorts: null,
		hasQuery: '1',
		isedit: '0',
		isshow: '1',
		funid: 'store_mat'
	};
	
	
	config.eventcfg = {
		
	printPDF: function(){
		var self = this;
		var records = JxUtil.getSelectRows(self.grid);
		if (!JxUtil.selected(records)) return;
        
        var nodeid = self.define.nodeid;
		//取选择记录的主键值
        var params = 'funid='+ nodeid +'&query_funid='+ nodeid;
        for (var i = 0; i < records.length; i++) {
            params += '&keyid=' + records[i].get(self.define.pkcol);
        }
        //设置请求的参数
        params += '&eventcode=pdfnew&model_id=jxstar8321';
		
        var hdcall = function(data) {
            var filename = data.filename;
            if (!filename) {
                JxHint.alert('not find pdf file!');
                return;
            }
            var e = encodeURIComponent;
            var params = 'funid='+nodeid+'&eventcode=pdfdown&filename=' + e(filename);
            
            JxAttach.previewPDF('PDF_PRINT','PDF_PRINT.pdf',params);
        };
        //发送请求
        Request.postRequest(params, hdcall);
	}
        
}
		
	return new Jxstar.GridNode(config);
}